import { Socket } from 'socket.io-client';
import { AgentState } from './state/state';
import { StateMachine } from '../../service/stateMachine';
export class AgentContext extends StateMachine<AgentState> {

  public state: AgentState;
  private properties: { [x: string]: any } = {};

  private getProperty = (name: string) => {
    return this.properties[name];
  }

  private setProperty = (name: string, value: any) => {
    this.properties[name] = value;
  }

  getCurrentStateName() {
    return this.state.getStateName();
  }
  
  getSocketConnection(): Socket {
    return this.getProperty('socket');
  }

  saveSocketConnection(socket: Socket) {
    this.setProperty('socket', socket);
  }

  establishConnection = async () => {
    this.state.establishConnection();
  }

  registerAbilities = async () => {
    this.state.registerAbilities();
  }

  onSimulationRequest = async () => {
    this.state.onSimulationRequest();
  }
}